//
//  exampleViewController.m
//  car
//
//  Created by chenxu on 15/3/12.
//  Copyright (c) 2015年 chenxu. All rights reserved.
//

#import "exampleViewController.h"

@interface exampleViewController ()

@end

@implementation exampleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadinfo:_index];
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:true];
    
    CGFloat padding =20;
    CGFloat width = kScreen_Width - padding*2;
    UIFont *font = _intro.font;
    NSString* string  = _intro.text;
    //CGSize size = [string getSizeWithFont:font constrainedToSize:CGSizeMake(kScreen_Width, 400)];
    _intro.frame = CGRectMake(padding, 400, kScreen_Width, 700);
 //   _name.frame = CGRectMake(padding, padding, width, 20);
    _scrollView.frame = CGRectMake(0, 0, kScreen_Width, self.view.frame.size.height);
    _scrollView.contentSize = CGSizeMake(kScreen_Width, kScreen_Height);

}

/*!
 *  @brief  读取各种车险的详细信息
 *  @param index 车险编号
 */
- (void)loadinfo:(NSString*)index{
    NSDictionary* datas = [NSObject loadPlist:@"insuranceinfo"];
    if (datas) {
        NSDictionary* data = [datas objectForKey:index];
        _name.text = [[NSString alloc]initWithFormat:@"%@.%@",index,[data objectForKey:@"name"]];
        _intro.text = [[NSString alloc]initWithString:[data objectForKey:@"intro"]];
        _why.text = [[NSString alloc]initWithString:[data objectForKey:@"example"]];//两个存反了，懒得改了
        _example.text = [[NSString alloc]initWithString:[data objectForKey:@"why"]];//两个存反了，懒得改了
    }
}



@end
